﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace WeatherFrame
{
    public class ItemTemplateSelector : ContentControl
    {

        protected override void OnContentChanged(object oldContent, object newContent)
        {
            var dt = new DataTemplate();
            if (newContent is WeatherItem)
            {
                dt = App.Current.Resources["WeatherItem"] as DataTemplate;
            }
            else if (newContent is List<WeatherItem>)
            {
                dt = App.Current.Resources["WeatherItemList"] as DataTemplate;
            } else if (newContent is WeatherModel)
            {
                dt = App.Current.Resources["LocationList"] as DataTemplate;
            }
            //if (ContentTemplate!=dt)
                ContentTemplate = dt;
        }
    }
}
